<?php

namespace app\index\model;

use think\Model;

class Account extends Model
{
    protected $table = 'cj_wechat_account';

    protected $autoWriteTimestamp = 'datetime';
    protected $createTime = 'created';
    protected $updateTime = false;

    /**
     * 返回已选择分组随机的一个号
     */
    public static function getAccount($groupIds)
    {
        $accounts = self::whereIn('group_id', $groupIds)
                    ->where(array('status' => 1))->select();
        if ($accounts) {
            return $accounts[rand(0, count($accounts)-1)];
        }
    }
}
